package com.yonyou.isv.demo.openapi.api.dept;

import com.yonyou.isv.demo.openapi.api.*;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataArrayResponse;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataResponse;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @description: 用友开放平台部门接口
 * @author: nishch
 * @create: 2021-07-05
 **/
@Component
public class DeptApi extends BaseOpenApi{

    public Map<String, Object> save(Map<String, Object> params) {
        ApiDataResponse apiDataResponse =  postForEntity(OpenApiURL.DEPT_SAVE,params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    public Map<String, Object> detail(Map<String, String> params) {
        ApiDataResponse apiDataResponse =  getForEntity(OpenApiURL.DEPT_DETAIL,params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 部门条件查询-平铺展示
     * @param params 请求条件
     * @return List<Map<String, Object>>
     */
    public List<Map<String, Object>> list(Map<String, Object> params) {
        ApiDataArrayResponse apiDataResponse =  postForEntity(OpenApiURL.DEPT_QUERY_LIST,params, ApiDataArrayResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 部门树查询
     * @param params 请求条件
     * @return List<Map<String, Object>>
     */
    public List<Map<String, Object>> tree(Map<String, Object> params) {
        ApiDataArrayResponse apiDataResponse =  postForEntity(OpenApiURL.DEPT_QUERY_TREE,params, ApiDataArrayResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 部门保存-导入
     * @param params
     * @return
     */
    public Map<String,Object> saveDto(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.DEPT_SAVEDTO, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
}
